cmake_minimum_required(VERSION 3.10)

project(ped)

# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90 -Os -g")

aux_source_directory(./src SRC)
aux_source_directory(./src/db DBSRC)
aux_source_directory(./src/config CONFIGSRC)
aux_source_directory(./src/module MODULESRC)
aux_source_directory(./src/mqtt MQTTSRC)

#include_directories
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../common/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../db/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/db)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/config)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/module)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/mqtt)
include_directories(${CMAKE_INCLUDE_OUTPUT_DIRECTORY}/logger)


#library_directories
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib)
link_directories(${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
link_directories(${CMAKE_CURRENT_SOURCE_DIR}/../ThirdParty/settings/lib/${ARCH})
# LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src/common)
# LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src/settings)
# LINK_DIRECTORIES(${CMAKE_BINARY_DIR}/src/db)


add_executable(${PROJECT_NAME} ${SRC} ${DBSRC} ${MQTTSRC} ${CONFIGSRC} ${MODULESRC}) # 生成可执行文件

#TARGET_LINK_LIBRARIES(ped xxx.so)
TARGET_LINK_LIBRARIES(${PROJECT_NAME} settings EasyLogger db common mosquitto crypto ssl cjson pthread)

add_custom_command(TARGET  ${PROJECT_NAME}
        POST_BUILD
        COMMAND echo "${PROJECT_NAME} builded finished."
        COMMAND ${CMAKE_COMPILER_STRIP} "$<TARGET_FILE:${PROJECT_NAME}>"
        COMMAND ${CMAKE_COMMAND} -E copy  $<TARGET_FILE:${PROJECT_NAME}> ${CMAKE_INSTALL_BINARY_DIR}
)
      